package com.ruoyi.buss.utils;

import java.text.DecimalFormat;

/**
 * Created by LiChangjiang on 2019-7-17 18:09:57
 */
public class IntegerUtil
{
    /**
     * 返回第一个数字除以第二个数得到的百分数
     * @param part
     * @param total
     * @return
     */
    public static String int2String(int part,int total)
    {
        if(0==part||0==total)
        {
            return "0.00%";
        }
        Double p=new Double(part);
        Double t=new Double(total);
        double result = p/t;
        DecimalFormat df = new DecimalFormat("0.00%");
        return df.format(result);
    }


    public static Double praseDouble(int part,int total)
    {
        if(0==part||0==total)
        {
            return 0.00;
        }
        Double p=new Double(part);
        Double t=new Double(total);
        double result = p/t;
        return result;
    }
    /**
     * 用于报表排序，将进度乘去掉小数点后返回数字类型结果
     * @param source String
     * @return int
     */
    public static int String2Int(String source)
    {
        source = source.replace(".","");
        source = source.replace("%","");
        return Integer.valueOf(source);
    }

    public static void main(String[] args) {
      System.out.println(  IntegerUtil.int2String(3,10));
    }

}
